/**
 * Service Class
 * 
 * */
package com.allergan.ws.ArgusServices;

import java.sql.Date;

import javax.activation.DataHandler;

import com.allergan.dao.AGNDao;
import com.allergan.model.AGNCaseDetail;

public class AGNService {
	
	private AGNDao dao;
	
	/**
	 * Service method to initiate an investigation request
	 * @param caseNum
	 * @param lotNum
	 * @param sampleInd
	 * @param status
	 * @return AGNCaseDetail object
	 * @throws Exception
	 */
	public AGNCaseDetail initiateInvestigationRequest(String caseNum, String lotNum, String sampleInd, String status) throws AGNServiceException{
		dao =  new AGNDao();
		return dao.getAGNCaseDetail(caseNum, lotNum, sampleInd, status); 
	}
	
	/**
	 * Method to finalize the request as completed
	 * @param requestId
	 * @return status
	 * @throws Exception
	 */
	public String finalizeInvestigationRequest(int requestId, String status, String statusReason, String cumSpecResult, Date statusDate) throws AGNServiceException{
		dao =  new AGNDao();
		return dao.markCompletedInSpec(requestId, status, statusReason, cumSpecResult, statusDate); 
	}
	
	/**
	 * Method to attach a report to the case,
	 * takes a java Blob as a file input
	 * @param caseNum
	 * @param classification
	 * @param fileName
	 * @param fileBlob
	 * @param notes
	 * @param keywords
	 * @param commitInd
	 * @return status
	 * @throws Exception
	 */
	public String attachPCRReport(String caseNum, String classification, String fileName, DataHandler data, 
			String notes, String keywords, int commitInd) throws AGNServiceException{
		dao =  new AGNDao();
		return dao.attachReport(caseNum, classification, fileName, data, notes, keywords, commitInd); 
	}
	
	class AGNServiceException extends Exception {
		private static final long serialVersionUID = 265895763749353702L;

		public AGNServiceException(String message) {
	        super(message);
	    }

	    public AGNServiceException(String message, Throwable throwable) {
	        super(message, throwable);
	    }
	}
	     
}